#pragma once

#include <string>
#include <iostream>
#include <windows.h>
#include <tchar.h>
#include <strsafe.h>
#include "stdafx.h"

using namespace std;

class Thread
{
public:
	enum ThreadPriority
	{
		PRIORITY_LOW = THREAD_PRIORITY_LOWEST,
		PRIORITY_BELOW_NORMAL = THREAD_PRIORITY_BELOW_NORMAL,
		PRIORITY_NORMAL = THREAD_PRIORITY_NORMAL,
		PRIORITY_ABOVE_NORMAL = THREAD_PRIORITY_ABOVE_NORMAL,
		PRIORITY_HIGH = THREAD_PRIORITY_HIGHEST
	};

	Thread(ThreadPriority p = PRIORITY_NORMAL, string nme="");
	~Thread();
	bool start();
	bool setPriority(ThreadPriority p);
	ThreadPriority getPriority();
	string getName();
	virtual void run() = 0;

protected:
	HANDLE hThread;

private:
	ThreadPriority priority;
	string name;
	DWORD threadId;
	static void* threadMapper(void* p);
};

class SleepTimer
{
public:
	SleepTimer();
	~SleepTimer();
	void sleep(unsigned long ms);
};